<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateWechatDataTables extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('basic_wechat_login', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->string('unionid')->unique()->comment('用于关联');
            $table->string('openid')->comment('微信登录用户openid');
            $table->string('exam_code')->comment('学生考试号');
            $table->softDeletes();
            $table->timestamps();
            // 外键关联
            $table->foreign('exam_code')->references('exam_code')->on('basic_new_students')
                ->onDelete('restrict')->onUpdate('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('basic_wechat_login');
    }
}
